<%-- 
    Document   : AddUser
    Created on : Dec 9, 2011, 1:13:48 AM
    Author     : hendrikde
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<% if(session.getAttribute("LoggedIn")==null)
       {
    response.sendRedirect("index.html");
    return;
        }

%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Add User</title>
    </head>
    <body>
        <%
        String user_id = request.getParameter("PERS");
        String circle_id = request.getParameter("CIRC");
        
        DBClasses.GetConnection gc = new DBClasses.GetConnection();
        java.sql.Connection conn = gc.getConnection();
        
        try {
        
        java.sql.Statement stmt = conn.createStatement();
               
        
        
        String query = "UPDATE Tentatives SET OwnerApproved=1, CustomerApproved=1 WHERE CustomerID=" + user_id + " AND CircleID=" + circle_id;
        System.out.println(query);
        stmt.execute(query);
        query = "INSERT INTO circlemembership (CustomerID, CircleID) VALUES (" + user_id + ", " + circle_id + ")";
        System.out.println(query);
        conn.createStatement().execute(query);
        
               }
        
                catch(Exception e) {
            e.printStackTrace();
        }
        finally
    {
        try{
            conn.commit();
            conn.close();
            response.sendRedirect("gohome.jsp");
        }
        catch(Exception ee)
                               {
                ee.printStackTrace();
            }
        }
        %>
    </body>
</html>
